﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPGProject.GameWorld.GameObjects
{
    /// <summary>
    /// An event class.
    /// </summary>
    class GameObjectEvent
    {
        /// <summary>
        /// The name of the event.
        /// </summary>
        private readonly String name;
        public String Name
        {
            get { return this.name; }
            set { }
                
        }
        private Dictionary<String, object> args;
        /// <summary>
        /// Creates a GameObjectEvent named as such.
        /// </summary>
        /// <param name="name">Name of the event.</param>
        public GameObjectEvent(String name)
        {
            this.name = name;
            args = new Dictionary<String, object>();
        }
        public object this[String index]
        {
            get { return this.args[index]; }
            set { this.args[index] = value; }
        }
        public override string ToString()
        {
            String ret = "Event: " + this.Name + "; Args: ";
            foreach(String key in this.args.Keys)
            {
                ret += "(" + key + ": " + this.args[key] + "); ";
            }
            return ret;
        }
        /// <summary>
        /// Checks to see if the event has a certain key.
        /// </summary>
        /// <param name="p">The key to be checked.</param>
        /// <returns>Whether the key exists or not.</returns>
        public bool Has(String p)
        {
            return this.args.ContainsKey(p);
        }
        /// <summary>
        /// Moves all parameters from one event to another.
        /// </summary>
        /// <param name="e"></param>
        public void Grab(GameObjectEvent e)
        {
            foreach (String key in e.args.Keys)
            {
                this[key] = e[key];
            }
        }
    }
}
